const express = require("express");
const {randomCode,sendCode}=require("./router/getMessage");

const app=express();//实例

const cors =require('cors')
app.use(cors());

app.get("/login",(req,res)=>{
    console.log(req.query);
    sendCode(req.query.phone,req.query.ma,function(success){
        if(success){
            res.send({code:req.query.ma,msg:"短信验证码已发送"});
        }else{
            res.send("短信验证码发送失败");
        }
    })
})

const server=app.listen(4200,function(){
    const {address,port}=server.address();
    console.log(address,port);
    console.log("HTTP服务已启动");
});